package com.fin.quant.server.rpc;

import com.fin.quant.rpc.bean.server.GrpcService;
import com.fin.quant.rpc.proto.AlgoServiceGrpc;
import com.fin.quant.rpc.proto.PredictReply;
import com.fin.quant.rpc.proto.PredictRequest;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
@GrpcService("AlgoServiceServer")
public class AlgoServiceRpc extends AlgoServiceGrpc.AlgoServiceImplBase {

    @Override
    public void predict(PredictRequest request, StreamObserver<PredictReply> responseObserver) {
        String input = request.getInput();
        log.info("AlgoService.input={}",input);
        String result="AlgoService return.";

        PredictReply reply= PredictReply.newBuilder().setResult(result).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}
